package com.xbongbong.paas.domain.entity.ext;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormEntity;
import com.xbongbong.paas.field.LinkListPojo;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.Objects;

/**
 * @author: wufeng
 * @date: 2018/8/14 14:17
 * @desrcption: 协同人权限
 */
@Getter
@Setter
public class PaasFormEntityExt extends PaasFormEntity {

    private static final long serialVersionUID = -6403045589557009212L;


    private CoOpPermsEntityExt coOpPermsExt;

    public CoOpPermsEntityExt getCoOpPermsExt() {
        return coOpPermsExt;
    }

    public void setCoOpPermsExt(String coOpPerms) {
        this.coOpPermsExt = JSONObject.parseObject(coOpPerms, CoOpPermsEntityExt.class);
    }

    /**
     * 数据摘要
     */
    private JSONArray summaryList;

    /**
     * 数据标签
     */
    private JSONArray labelsList;

    private Integer enable;
    /**
     * saas业务名称
     */
    private String businessName;
    /**
     * 业务类型主键字段(用于关联列表回显)
     */
    private String mainAttr;

    /**
     * 列表显示字段
     */
    private List<String> fieldList;
    /**
     * 唯一code
     */
    private Integer code;

    /**
     * 表单id
     */
    @Deprecated
    private Long formId;

    private Integer packageLimit;

    private Integer upgrade;

    private String message;

    /**
     * 转list后的associationList
     */
    private List<LinkListPojo> linkListList;

    public JSONArray getSummaryList() {
        return summaryList;
    }

    public void setSummaryList(String summary) {
        this.summaryList = JSONArray.parseArray(summary);
    }

    public JSONArray getLabelsList() {
        return labelsList;
    }

    public void setLabelsList(String labels) {
        this.labelsList = JSONArray.parseArray(labels);
    }

    public PaasFormEntityExt() {
    }

    public List<LinkListPojo> getLinkListList() {
        if (Objects.isNull(this.linkListList)) {
            return JSONArray.parseArray(this.getAssociationList(), LinkListPojo.class);
        } else {
           return linkListList;
        }
    }

    public PaasFormEntityExt(String corpid, Long appId, Long menuId, String name, Integer saasMark, Integer businessType, Integer enable, Integer isProcessForm, String verifyRule, Integer disableFieldAssign, Integer frontCache, Integer titleType, String customTitle, String associationList, String businessRules, String summary, String fieldPosition, Integer distributorMark) {
        super(corpid, appId, menuId, name, saasMark, businessType, enable, isProcessForm, verifyRule, disableFieldAssign, frontCache, titleType, customTitle, associationList, businessRules,  summary, fieldPosition,  distributorMark);
    }
}
